home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / c / libiconv_src.lha / src / genflags.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-07  |  3.3 KB  |  104 lines

  1. /* Copyright (C) 2000 Free Software Foundation, Inc.
  2.    This file is part of the GNU ICONV Library.
  3.  
  4.    The GNU ICONV Library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public License as
  6.    published by the Free Software Foundation; either version 2 of the
  7.    License, or (at your option) any later version.
  8.  
  9.    The GNU ICONV Library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU Library General Public
  15.    License along with the GNU ICONV Library; see the file COPYING.LIB.  If not,
  16.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  17.    Boston, MA 02111-1307, USA.  */
  18.  
  19. /* Creates the flags.h include file. */
  20.  
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23.  
  24. /* Consider all encodings, including the system dependent ones. */
  25. #define USE_AIX
  26.  
  27. #include "converters.h"
  28.  
  29. static void emit_encoding (struct wctomb_funcs * ofuncs, const char* c_name)
  30. {
  31.   /* Prepare a converter struct. */
  32.   struct conv_struct conv;
  33.   memset(&conv,'\0',sizeof(conv));
  34.   conv.ofuncs = *ofuncs;
  35.  
  36.   {
  37.     /* See whether the encoding can encode the accents and quotation marks. */
  38.     wchar_t probe[6] = { 0x0060, 0x00b4, 0x2018, 0x2019, 0x3131, 0x3163, };
  39.     int res[6];
  40.     int i;
  41.     for (i = 0; i < 6; i++) {
  42.       unsigned char buf[10];
  43.       memset(&conv.ostate,'\0',sizeof(state_t));
  44.       res[i] = (conv.ofuncs.xxx_wctomb(&conv,buf,probe[i],sizeof(buf)) != 0);
  45.     }
  46.     printf("#define ei_%s_oflags (",c_name);
  47.     {
  48.       int first = 1;
  49.       if (res[0] && res[1]) {
  50.         printf("HAVE_ACCENTS");
  51.         first = 0;
  52.       }
  53.       if (res[2] && res[3]) {
  54.         if (!first) printf(" | ");
  55.         printf("HAVE_QUOTATION_MARKS");
  56.         first = 0;
  57.       }
  58.       if (res[4] && res[5]) {
  59.         if (!first) printf(" | ");
  60.         printf("HAVE_HANGUL_JAMO");
  61.         first = 0;
  62.       }
  63.       if (first) printf("0");
  64.     }
  65.     printf(")\n");
  66.   }
  67. }
  68.  
  69. int main ()
  70. {
  71.   int bitmask = 1;
  72.   printf("/* Generated automatically by genflags. */\n");
  73.   printf("\n");
  74.   printf("/* Set if the encoding can encode\n");
  75.   printf("   the acute and grave accents U+00B4 and U+0060. */\n");
  76.   printf("#define HAVE_ACCENTS %d\n",bitmask);
  77.   printf("\n");
  78.   bitmask = bitmask << 1;
  79.   printf("/* Set if the encoding can encode\n");
  80.   printf("   the single quotation marks U+2018 and U+2019. */\n");
  81.   printf("#define HAVE_QUOTATION_MARKS %d\n",bitmask);
  82.   printf("\n");
  83.   bitmask = bitmask << 1;
  84.   printf("/* Set if the encoding can encode\n");
  85.   printf("   the double-width Hangul letters (Jamo) U+3131 to U+3163. */\n");
  86.   printf("#define HAVE_HANGUL_JAMO %d\n",bitmask);
  87.   printf("\n");
  88.  
  89. #define DEFENCODING(xxx_names,xxx,xxx_ifuncs,xxx_ofuncs1,xxx_ofuncs2) \
  90.   {                                                       \
  91.     struct wctomb_funcs ofuncs = xxx_ofuncs1,xxx_ofuncs2; \
  92.     emit_encoding(&ofuncs,#xxx);                          \
  93.   }
  94. /* Consider all encodings, including the system dependent ones. */
  95. #include "encodings.def"
  96. #include "encodings_aix.def"
  97. #undef DEFENCODING
  98.  
  99.   fflush(stdout);
  100.   if (ferror(stdout))
  101.     exit(1);
  102.   exit(0);
  103. }
  104.